// components/ReceiveSuccess/ReceiveSuccess.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    isShow: false,//显示弹窗
    isshowText:false,//显示底部文字
    couponImg:'/image/voucher-bg.png',//显示代金券图片
    couponMoney:"0",//代金券金额
    isShowGood:false,//显示实物图片
    isShowCoupon:true,//显示券图片
    goodImg:'/image/look.png',//显示实物或未抽中的图片
    bottomText:"",//底部提示文字
    buttonText:"领取",//按钮文字
    titleBg:"/image/dialog-bg-1.png",//title上面的背景图片
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //显示弹窗
    showDialog: function () {
      var that = this;
      that.setData({
        isShow: true
      })
    },
    //隐藏弹窗
    hiddenDialog: function () {
      var that = this;
      that.setData({
        isShow: false
      })
    },

    //显示文字
    showText:function(){
      this.setData({
        isshowText:true
      })
    },
    //隐藏文字
    hiddenText:function(){
      this.setData({
        isshowText: false
      })
    },

    //根据获取到的奖品类型做跳转
    // typeJump:function(type){
    //   var that=this;
    //   if (type==1){
    //     that.hiddenText();
    //   }else if(type==2){
    //     wx.navigateTo({
    //       url: '../MyPrize/PrizeDetail',
    //     })
    //   }
    // },

    //根据类型修改图片
    changeImg:function(type,money,img,name){
      var that=this
      //修改为0-50的券
      if (type == 1){
        that.setData({
          couponImg: '/image/voucher-bg.png',
          titleBg: "/image/dialog-bg-1.png",
          couponMoney: money,
          isshowText:false,
          isShowCoupon:true,
          isShowGood:false,
          buttonText:'领取'
        })
      }
      //修改为51-100的券
      if (type == 2){
        that.setData({
          couponImg: '/image/voucher-bg-2.png',
          titleBg: "/image/dialog-bg-1.png",
          couponMoney: money,
          isshowText: false,
          isShowCoupon: true,
          isShowGood: false,
          buttonText: '领取'
        })
      }

      //修改为101-200的券
      if (type == 3) {
        that.setData({
          couponImg: '/image/voucher-bg-3.png',
          titleBg: "/image/dialog-bg-1.png",
          couponMoney: money,
          isshowText: false,
          isShowCoupon: true,
          isShowGood: false,
          buttonText: '领取'
        })
      }
      if(type==4){
        that.setData({
          goodImg: img,
          titleBg: "/image/dialog-bg-1.png",
          isshowText: true,
          isShowCoupon: false,
          isShowGood: true,
          bottomText: name,
          buttonText:"查看兑奖说明"
        })
      }
      if (type == 5) {
        that.setData({
          goodImg: img,
          titleBg: "/image/dialog-bg-1.png",
          isshowText: true,
          isShowCoupon: false,
          isShowGood: true,
          bottomText: name,
          buttonText: "查看兑奖说明"
        })
      }

      if(type == 6){
        that.setData({
          goodImg: '/image/look.png',
          titleBg: "/image/dialog-bg-2.png",
          isshowText: true,
          isShowCoupon: false,
          isShowGood: true,
          bottomText: "手滑了,请再接再厉~",
           buttonText: "继续"
        })
      }
    },

    //显示实物

    _checkPrize: function () {
      this.triggerEvent("checkPrize")
    }
  }
})
